package pcb.models 
{
	import com.intel.patterns.observer.Subject;
	import com.intel.utils.Debugger;
	import flash.utils.Dictionary;
	
	/**
	 * The intention is to make this a central repository for localisation used in slides
	 * subclasses of UIComponent that are used as base classes for Flash library components
	 * will have a modellocator property that can reference AssetModel
	 * 
	 * @author Fintan Boyle
	 */
	public class LocaleModel extends Subject implements IModel 
	{
		public var language:String;
		public var culture:String;
		
		/**
		 * standard labels used throughout the application
		 */
		private var labels:Dictionary;
		
		public function LocaleModel() 
		{
			Debugger.traceOut("LocaleModel constructed");
			labels = new Dictionary(true);
		}
		
		public function addLabel(id:String, label:String):void 
		{
			labels[id] = label;
		}
		
		public function addLabels(data:XML):void 
		{
			if (data != null) {
				
				for each(var item:XML in data.children()) {
					if (item.hasComplexContent()) {						
						addLabels(item);
					} else {
						addLabel(item.name(), item.toString());
					}
				}
			}
		}
		
		
		public function getLabelbyId(id:String):String
		{
			var s:String = labels[id];
			
			if (s == null) {			
				Debugger.traceOut("Could not locate label with ID: " + id, Debugger.ERROR);
				return "Label Error"
			}
			return s;
		}
		
		public function notifyViews(str:String):void 
		{
			notify(str);
		}
		
		/**
		 * updates AssetModel with localised audio/images/text/swfs
		 * note: soundModel.soundIds should not need to be updated because
		 * xml datastrucuture should be consistent between locales
		 */
		public function updateAssetModel():void 
		{
			
		}
		
	}
	
}